<template>
    <view>
        <camera device-position="back" flash="off" style="width: 100%;height: 1200rpx;"></camera>
		<button class="cameraStyle" type="default" @tap="TakePhoto">拍照</button>
    </view>
</template>

<script>
    export default {
        data() {
            return {
				legal: ''
            }
        },
        onLoad(option) {//监听页面加载
	      this.legal = option.title
        },
        methods:{
            TakePhoto(){
                const camera = uni.createCameraContext() //创建照相机对象
                camera.takePhoto({//实现拍照功能
                    quality:'high', //high 高质量成像、 normal 普通质量、row 低质量
                    success: (res) => {
						console.log(res.tempImagePath, '相片路径3')
						let data = {
						    legal: this.legal,
						    tempImagePaths: res.tempImagePath
						}
						uni.setStorage({
							key: 'data',
							data: JSON.stringify(data),
						});
						uni.navigateBack({
							delta: 1  // delta值为1时表示返回的页面层数
						});
                    }
                })
            }
        }
    }
</script>
<style>
	.cameraStyle {
		margin: auto;
		position: fixed;
		bottom: 100rpx;
	}
</style>